import { Controller, Get, Post, Body, Patch, Param, Delete, Query, Put } from '@nestjs/common';
import { UsersService } from './users.service';
import {ApiTags} from "@nestjs/swagger"
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { User } from './entities/user.entity';
@ApiTags('用户')
@Controller('users')
export class UsersController {
  constructor(private readonly usersService: UsersService) {}
 
  @Post("/createUser")
  create(@Body() createUserDto: CreateUserDto) {
    return this.usersService.create(createUserDto);
  }

  @Get("getList")
  findAll():Promise<User[]> {
    return this.usersService.findAll();
  }

  @Get('detail')
  findOne(@Query('id' ) id:number) {
    return this.usersService.findOne(id);
  }

  @Post('update')
  update(@Body() updateUserDto: UpdateUserDto) {
    console.log(updateUserDto)
    return this.usersService.update(updateUserDto);
  }

  @Delete('del/:id')
  remove(@Param('id') id:number) {
    return this.usersService.remove(id);
  }
}
